import {getRoadSelectList, getRoadSectionSelectList, getSlopeSelectList,getDamageSelectList} from '@/services/model/road-mgmt'

import constUrl from '@/services/env'
import Format from '@/utils/format'

export default {
  props: ['roadId'],
  data() {
    return {
      //评分选项
      itemList: [
        {code: 0, group: '隐患管理(10分)', standard: '8分', min:0,max:8, score: '', name: '未制定公路边坡及地质灾害隐患排查治理制度'},
        {code: 1, group: '', standard: '2分', min:0,max:2, score: '', name: '未开展公路边坡及地质灾害隐患排查治理培训'},
        {code: 2, group: '隐患排查(40分)', standard: '5~10分', min:0,max:10, score: '', name: '未按规定开展日常排查、定期排查、专项排查，或日常排查工作不连续'},
        {code: 3, group: '', standard: '3~6分', min:0,max:6, score: '', name: '未安排专人专职开展日常排查'},
        {code: 4, group: '', standard: '3~6分', min:0,max:6, score: '', name: '排查记录缺失、不连续、不闭合'},
        {code: 5, group: '', standard: '5~10分', min:0,max:10, score: '', name: '未建立隐患清单或台账，或清单、台账不全面、不闭合'},
        {code: 6, group: '', standard: '4~8分', min:0,max:8, score: '', name: '未对隐患排查情况进行复查验证'},

        {code: 7, group: '隐患治理(25分)', standard: '1~3分', min:0,max:3, score: '', name: '隐患治理情况未进行通报'},
        {code: 8, group: '', standard: '2~5分', min:0,max:5, score: '', name: '隐患治理方案的责任、措施、资金、时限不落实'},
        {code: 9, group: '', standard: '2~5分', min:0,max:5, score: '', name: '排查出隐患未及时整改，或问题整改不闭合'},
        {code: 10, group: '', standard: '1~3分', min:0,max:3, score: '', name: '未限期整改隐患'},
        {code: 11, group: '', standard: '3~6分', min:0,max:6, score: '', name: '未对隐患整改情况进行复查验证'},
        {code: 12, group: '', standard: '1~3分', min:0,max:3, score: '', name: '未定期统计分析事故隐患治理情况'},

        {code: 13, group: '重大隐患排查治理(25分)', standard: '3~6分', min:0,max:6, score: '', name: '重大隐患未及时按规定报备'},
        {code: 14, group: '', standard: '3~6分', min:0,max:6, score: '', name: '未制定重大隐患治理方案、应急预案'},
        {code: 15, group: '', standard: '2~5分', min:0,max:5, score: '', name: '重大地质灾害隐患未按规定采取必要安全防控措施，未建立警戒区域等'},
        {code: 16, group: '', standard: '2~4分', min:0,max:4, score: '', name: '未对专项施工方案实施情况进行分析评价'},
        {code: 17, group: '', standard: '2~4分', min:0,max:4, score: '', name: '重大地质灾害隐患未实施安全监测'},
      ],
      // 列表勾选的数据
      selectionList: [],
      roadList: [],
      sectionList: [],
      fileList: [],
      bidSlopeList: [],
      bidDamageList: [],
      slopeList: [],
      damageList: [],
      bidSectionList: [],
      otherWater: false,
      otherGroundWater: false,
      otherEasy: false,
      otherSpecial: false,
    }
  },
  filters: {

    // 时间格式化
    formatTimer(timer) {
      if (timer) {
        return Format(new Date(timer), 'yyyy-MM-dd hh:mm:ss')
      }
      return ''
    },
    // 时间格式化
    formatTimer2(timer) {
      if (timer) {
        return Format(new Date(timer), 'yyyy-MM-dd')
      }
      return ''
    },
    // 时间格式化
    formatTimer3(timer) {
      if (timer) {
        return Format(new Date(timer), 'yyyy年MM月dd日')
      }
      return ''
    },

    gradeCheckColor(val) {
      switch (val) {
        case '销号驳回':
          return 'danger'
        case '整改超时':
          return 'danger'
        case '已销号':
          return 'success'
        default:
          return ''
      }
    },
    gradeRiskLevelColor(val) {
      switch (val) {
        case 0:
          return 'background-color:#0DC26B'
        case 1:
          return 'background-color:#0073b7'
        case 2:
          return 'background-color:#f39c12'
        case 3:
          return 'background-color:#ff851b'
        case 4:
          return 'background-color:#e43321'
        default:
          return 'background-color:#ffffff'
      }
    },
    gradeCheckLevelColor(val) {
      switch (val) {
        case '优':
          return 'success'
        case '良':
          return ''
        case '中':
          return 'info'
        default:
           return 'danger'
      }
    },
    gradeDangerColor(val) {
      switch (val) {
        case '正常':
          return 'background-color:#0DC26B'
        case '一般隐患':
          return 'background-color:#0073b7'
        case '重大隐患':
          return 'background-color:#e43321'
        default:
          return 'background-color:#0DC26B'
      }
    },
    gradeTypeColor(val) {
      switch (val) {
        case '水毁':
          return 'color:#0DC26B'
        case '泥石流':
          return 'color:#0073b7'
        case '沉陷与塌陷':
          return 'color:#e43321'
        case '滑坡':
          return 'color:#E6A23C'
        default:
          return 'color:#303133'
      }
    },
    gradeNoticeColor(val) {
      switch (val) {
        case '隐患上报':
          return 'color:#0DC26B'
        case '整改通知':
          return 'color:#0073b7'
        case '停工通知':
          return 'color:#e43321'
        case '监督检查表':
          return 'color:#0DC26B'
        case '抽查意见通知书':
          return 'color:#e43321'
        case '通用警告函':
          return 'color:#0073b7'
        default:
          return 'color:#0DC26B'
      }
    }
  },
  methods: {
    formatCheckStatus(name,overStatus){
      if(overStatus === 1){
        name = name+'(超时)'
      }
      return name;
    },
    //处理文件下载地址
    filePathHandle(val) {
      if(val){
        this.fileList = val.map(x => {
          return {
            url: constUrl + x.url,
            name: x.name
          }
        })
        return this.fileList
      }else{
        return []
      }
    },
    //获取组织下的路线列表
    async getRoadListByDept(deptId) {
      const {data} = await getRoadSelectList({deptId:deptId})
      return data
    },
    //获取路线列表
    async getRoadList() {
      const {data} = await getRoadSelectList()
      this.roadList = data
    },
    //根据路线id获取标段列表
    async getBidSectionList(roadId) {
      const {data} = await getRoadSectionSelectList({roadId: roadId})
      this.bidSectionList = data
      this.sectionList = data
    },
    //根据标段id获取边坡列表
    async getSelectSlopeList(bidSectionId) {
      const {data} = await getSlopeSelectList({roadSectionId: bidSectionId,flag:0})
      this.bidSlopeList = data
      this.slopeList = data
    },
    //根据标段id获取边坡列表
    async getDamageSelectList(roadId,type) {
      const {data} = await getDamageSelectList({roadId: roadId,damageType:type})
      this.bidDamageList = data
      this.damageList = data
    },
    // 删除设计资料-防护信息
    handleDeleteProtectionDetail(index) {
      this.currentRow.protectionDetailList.splice(index, 1)
    },
    // 添加设计资料-防护信息
    addProtectionDetail() {
      let item = {
        level: '',           //级数
        gradient: "",       //坡率
        dept: "",           //支护措施
        size: "",         //规格尺寸
        count: '',           //数量
        remark: "",
      }
      this.currentRow.protectionDetailList.push(item)
    },
    //如果技术资料-地表排水措施选择其他
    ChangeOtherWater() {
      if (this.currentRow.waterDrainStepList.indexOf(5) > -1) {
        this.otherWater = true
      } else {
        this.otherWater = false
      }
    },
    //如果技术资料-地下排水措施选择其他
    ChangeOtherGroundWater() {
      if (this.currentRow.groundwaterDrainStepList.indexOf(5) > -1) {
        this.otherGroundWater = true
      } else {
        this.otherGroundWater = false
      }
    },
    //如果技术资料-地表排水措施选择其他
    ChangeOtherEasyMonitor() {
      if (this.currentRow.easyMonitorPlanList.indexOf(3) > -1) {
        this.otherEasy = true
      } else {
        this.otherEasy = false
      }
    },
    //如果技术资料-地下排水措施选择其他
    ChangeOtherSpecialMonitor() {
      if (this.currentRow.specialMonitorPlanList.indexOf(5) > -1) {
        this.otherSpecial = true
      } else {
        this.otherSpecial = false
      }
    },
  },
  created() {
  },

}
